﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace frmPrincipalTestes
{
    public partial class Testes
    {
        public static bool ValidCode(string code)
        {
            bool valid = true;
            long auxcodigo;

            if (code.Trim() == "")
            {
                valid = false;
            }else if (!long.TryParse(code, out auxcodigo))
            {
                valid = false;
            }

            return valid;
        }

        public static bool ValidCPF(string CPF)
        {
            bool valid = true;

            if (!ValidCode(CPF))
            {
                valid = false;
            }
            else if (CPF.Length != 11)
            {
                valid = false;
            }

            return valid;
        }

        public static bool ValidCNPJ(string CNPJ)
        {
            bool valid = true;

            if (!ValidCode(CNPJ))
            {
                valid = false;
            }
            else if (CNPJ.Length != 14)
            {
                valid = false;
            }

            return valid;
        }

    }
}
